//Created by Erin Cassese
//For "Partisan Dehumanization in American Politics" in Political Behavior 
//Analysis of MTurk Data
///March 26, 2019

clear
* set file path here: cd " "
use "MTurk Study Data.dta"

* Data for Figure 1A-C

* Figure 1A 

mean HU_dem, over(pid3)

mean HU_dem if pid3==1
mean HU_dem if pid3==3
mean HU_rep if pid3==1
mean HU_rep if pid3==3

* Figure 2A

mean HN_dem if pid3==1
mean HN_dem if pid3==3
mean HN_rep if pid3==1
mean HN_rep if pid3==3

* Figure 3A 

mean ascent_demRS if pid3==1
mean ascent_demRS if pid3==3
mean ascent_repRS if pid3==1
mean ascent_repRS if pid3==3
	
* Table A2 Models - Online Appendix 

eststo clear
eststo: regress HN_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
eststo: regress HU_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust 
eststo: regress ascent_demRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust

eststo: regress HN_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
eststo: regress HU_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
eststo: regress ascent_repRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
esttab using TableA2.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)
eststo clear

* Robustness Check - Party Affect as a Covariate

eststo clear
eststo: regress HN_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust
eststo: regress HU_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust 
eststo: regress ascent_demRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust

eststo: regress HN_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust
eststo: regress HU_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust
eststo: regress ascent_repRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids diff_therm_partiesS, robust
esttab using Table_RCheck1.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)
eststo clear

* Figure 2A (fig2a_a.gph, fig2a_b.gph, and fig2a_c.gph must have been created from the student data prior to running these commands)

eststo: regress HU_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust 
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Animalistic (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Animalistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2a_d.gph" 

eststo: regress HN_dem i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Mechanistic (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Mechanistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2a_e.gph" 

eststo: regress ascent_demRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Blatant (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Blatant Dehumanization") ylabel(-1.5(.5)1.5) 
graph save "fig2a_f.gph" 

grc1leg  "fig2a_a.gph" "fig2a_b.gph" "fig2a_c.gph" "fig2a_d.gph" "fig2a_e.gph" "fig2a_f.gph",  rows(2) title("A. Evaluations of Democrats by Partisans in Two Samples")

* Figure 2B (fig2b_a.gph, fig2b_b.gph, and fig2b_c.gph must have been created from the student data prior to running these commands)

eststo: regress HU_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Animalistic (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Animalistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2b_d.gph" 

eststo: regress HN_rep i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Mechanistic (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Mechanistic Traits") ylabel(-1.5(.5)1.5) 
graph save "fig2b_e.gph" 

eststo: regress ascent_repRS i.pid2##c.identity age female black hispanic asian other edu employed inc church married kids, robust
margins pid2, at(identity=(-1.5(.5)1.5)) vsquish
marginsplot, recastci(rarea)  title ("Blatant (MTurk Sample)", size(medsmall)) xtitle("Identity Strength") ytitle("Blatant Dehumanization") ylabel(-1.5(.5)1.5) 
graph save "fig2b_f.gph" 
eststo clear

grc1leg  "fig2b_a.gph" "fig2b_b.gph" "fig2b_c.gph" "fig2b_d.gph" "fig2b_e.gph" "fig2b_f.gph",  rows(2) title("A. Evaluations of Republicans by Partisans in Two Samples")

* Table A3 - Online Appendix

* Panel B 

pwcorr identity HU_dem HN_dem ascent_demRS dem_therm if pid3==3, sig

* Panel D 
pwcorr identity HU_rep HN_rep ascent_repRS rep_therm if pid3==1, sig
	
* Table A5 Models - Online Appendix 

eststo clear
eststo: regress dem_social_distance identity diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==3
eststo: regress rep_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==1
eststo: regress moral_distance_parties identity diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==3
eststo: regress moral_distance_parties identity  diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==1
esttab using TableA5.rtf, b(2) se(2) ar2 star(+ 0.10 * 0.05 ** .01 *** .001)

* Data for Figure 3

regress dem_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==3
margins, at(diff_ascent_partiesS=(-.8536168 2.290605)) level(90)  contrast(atjoint effect)
regress rep_social_distance identity  diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==1
margins, at(diff_ascent_partiesS=(-.8536168 2.290605)) level(90)  contrast(atjoint effect)
regress moral_distance_parties identity diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==3
margins, at(diff_ascent_partiesS=(-.8536168 2.290605)) level(90)  contrast(atjoint effect)
regress moral_distance_parties identity  diff_ascent_partiesS diff_therm_partiesS age female black hispanic asian other edu employed inc church married kids if pid3==1
margins, at(diff_ascent_partiesS=(-.8536168 2.290605)) level(90)  contrast(atjoint effect)
	
* Table A6 - Online Appendix 

mean age
tab female
tab white
tab black
tab hispanic
tab asian
tab other
tab pid3 
tab ideo3 
tab follow
	
